set(LLVM_LINK_COMPONENTS support)

# Generate lexer and parser with ANTLR
list(APPEND CMAKE_MODULE_PATH "${ANTLR_RUNTIME}/cmake")
include(FindANTLR)
antlr_target(IRISCCGen "C.g4"
        LEXER PARSER
        OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
        VISITOR
)

add_library(IrisCCParser SHARED ${ANTLR_IRISCCGen_CXX_OUTPUTS})
target_include_directories(IrisCCParser PUBLIC ${ANTLR_RUNTIME}/runtime/src)
target_link_libraries(IrisCCParser PUBLIC antlr4_shared)

add_library(IrisCCIRGenerator SHARED
        ASTGenerator.cpp
)
set_target_properties(IrisCCIRGenerator PROPERTIES CXXSTANDARD 20 CXX_EXTENSIONS OFF)

target_include_directories(IrisCCIRGenerator PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(IrisCCIRGenerator PRIVATE IrisCCParser)